package com.iexbuy.ihg.ui.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.iexbuy.ihg.R;
import com.iexbuy.ihg.adapter.LingQianLastestListAdapter;
import com.iexbuy.ihg.entity.LingQianLastestObject;
import com.iexbuy.ihg.entity.LingQianLastestObjectResponse;
import com.iexbuy.ihg.entity.LingQianRecordObject;
import com.iexbuy.ihg.entity.LingQianSummaryObject;
import com.iexbuy.ihg.net.ServiceHelper;
import com.iexbuy.ihg.utils.JsonUtils;
import com.jingchen.pulltorefresh.PullToRefreshLayout;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class WeDeMianDanCashNumberFragment extends BaseFragment {

	private static WeDeMianDanCashNumberFragment homeFragmentInstent;


	@ViewInject(R.id.totalCashNumberTv)
	private TextView totalCashNumberTv;
	@ViewInject(R.id.receivedUserNumberTv)
	private TextView receivedUserNumberTv;
	@ViewInject(R.id.attenceUesrNumber)
	private TextView attenceUesrNumber;

	@ViewInject(R.id.curPosition)
	private TextView curPosition;
	@ViewInject(R.id.itemName)
	private TextView itemName;

	private LinearLayout listHeaderView;

	private String coinNumber;
	private String totalReceiveCash;
	private List<LingQianRecordObject> receivedRecords = new ArrayList<LingQianRecordObject>();
	private List<LingQianRecordObject> waitingRecords = new ArrayList<LingQianRecordObject>();
	private List<LingQianLastestObject>  lastRecords = new ArrayList<LingQianLastestObject>();
	private int pageNo = 0;
	private LingQianLastestListAdapter lingQianLastestListAdapter;

	private static LingQianSummaryObject summaryObject;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		homeFragmentInstent = this;
	}

	@Override
	protected View _onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_wede_miandan_casenumber_header, container, false);
		ViewUtils.inject(this, rootView);
		initView(rootView);
		return rootView;
	}

	private void initView(View rootView) {
		mBaseActivity.setTitle(getResources().getString(R.string.title_mian_dan));
		mBaseActivity.setTitleLayoutVisibility(true);
		mBaseActivity.setHomeActivity(false);

		initListView();

	}

	private void initListView() {
		if (summaryObject.getLastPostion()!=null){
			itemName.setVisibility(View.GONE);
		}else {
			itemName.setVisibility(View.VISIBLE);
		}
		totalCashNumberTv.setText(summaryObject.getTotalCashNumber());
		receivedUserNumberTv.setText(summaryObject.getReceivedUserNumber());
		attenceUesrNumber.setText(summaryObject.getAttandUserNumber());
		curPosition.setText(summaryObject.getLastPostion());

	}

	public static void setLingQianSummaryObject(LingQianSummaryObject summaryObject){
		WeDeMianDanCashNumberFragment.summaryObject = summaryObject;
	}
	/**
	 * @return the homeFragmentInstent
	 */
	public static WeDeMianDanCashNumberFragment getHomeFragmentInstent() {
		return homeFragmentInstent;
	}

}
